`timescale 1ns/1ps

module tb_Exp_Compress;

reg clock;
reg rst_n;
reg [511:0] msg_padding;
reg [255:0] V_in;
reg block_start;
wire [255:0] Vi_out;
wire block_comp_finished_out;

initial begin
    clock = 0;
    forever begin
        #5 clock = ~clock;
    end
end

initial begin
    rst_n = 0;
    #20 rst_n = 1;
end

initial begin
    msg_padding = 0;
    block_start = 0;
    V_in = 0;
    #30;
    msg_block_exp_com(512'h61626380_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000018,256'h7380166f_4914b2b9_172442d7_da8a0600_a96f30bc_163138aa_e38dee4d_b0fb0e4e);
    #50
    $finish;
end

always@(*) begin
    if(block_comp_finished_out) begin
    #1
        $display("block compress finished!");
        $display("round 63 compress result is: %64h @",Vi_out,$realtime);
        if(Vi_out == 256'h1547e69b_2bfa5f60_c6d696bc_069ae2e2_e808f43b_4ac3cf08_caf04e66_3fb0a6ae)
            $display("TEST PASS !");
        else
            $display("TEST ERROR ! CHECK COMPRESS VALUE!");
    end
end


Exp_Compress E_C_0(
    .clk_i(clock),
    .rst_n_i(rst_n),

    .msg_padding_in(msg_padding),
    .block_start_in(block_start),
    .V_in(V_in),

    .Vi_out(Vi_out),
    .block_comp_finished_out(block_comp_finished_out) 
);

task msg_block_exp_com;
    input [511:0] msg_block;
    input [255:0] Vi;
    
    begin
        @(negedge clock) begin
            msg_padding = msg_block;
            block_start = 1;
            V_in = Vi;
        end
        @(negedge clock) begin
            block_start = 0;
            msg_padding = 0;
//            V_in = 0;
        end
        wait(block_comp_finished_out);    
    end

endtask


endmodule //tb_Exp_Compress